package com.twang.stock.service.jinyan;

import com.twang.stock.entity.StockWarningEvent;
import com.twang.stock.mapper.StockWarningEventMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EventWarnService{
    @Resource
    private StockWarningEventMapper stockWarningEventMapper;

    public List<StockWarningEvent> queryEvent(String date, String type) {
        Example example = new Example(StockWarningEvent.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotBlank(date)) {
            criteria.andEqualTo("date", date);
        }
        if (StringUtils.isNotBlank(type)) {
            criteria.andEqualTo("type", type);
        }
        example.orderBy("warnTime").desc();
        return  stockWarningEventMapper.selectByExample(example);
    }
}
